<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>表达式和编码 | lilei</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/images/icons/logo.png">
    <link rel="apple-touch-icon" href="/images/icons/logo.png">
    <link rel="manifest" href="/manifest.json">
    <script type="text/javascript" src="/assets/js/load.js"></script>
    <meta name="description" content="个人网站">
    <meta name="twitter:title" content="表达式和编码">
    <meta name="twitter:description" content="">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:url" content="http://www.lileiblog.xyz/Other/%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%92%8C%E7%BC%96%E7%A0%81.html">
    <meta property="og:type" content="article">
    <meta property="og:title" content="表达式和编码">
    <meta property="og:description" content="">
    <meta property="og:url" content="http://www.lileiblog.xyz/Other/%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%92%8C%E7%BC%96%E7%A0%81.html">
    <meta property="og:site_name" content="lilei">
    <meta itemprop="name" content="表达式和编码">
    <meta itemprop="description" content="">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileImage" content="/images/icons/logo.png">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="keywords" content="lilei,vue,vuepress,vuepress-theme,theme,主题,vuepress主题,blog
        ,vuepress-blog,java,python,shell,sql,golang,script,shell script,nginx,windows,去广告,androd,google drive
        ,one drive,idea,eclipse,git,小程序">
    <meta name="referrer" content="never">
    
    <link rel="preload" href="/assets/css/0.styles.8932179b.css" as="style"><link rel="preload" href="/assets/js/app.269009d6.js" as="script"><link rel="preload" href="/assets/js/3.974b9720.js" as="script"><link rel="preload" href="/assets/js/42.fe4f877b.js" as="script"><link rel="prefetch" href="/assets/js/10.5915e99b.js"><link rel="prefetch" href="/assets/js/11.ff732762.js"><link rel="prefetch" href="/assets/js/12.8bb86d91.js"><link rel="prefetch" href="/assets/js/13.18bde5b0.js"><link rel="prefetch" href="/assets/js/14.314fae34.js"><link rel="prefetch" href="/assets/js/15.0a4ff48f.js"><link rel="prefetch" href="/assets/js/16.ffaf1503.js"><link rel="prefetch" href="/assets/js/17.49a31a6e.js"><link rel="prefetch" href="/assets/js/18.7e6443bf.js"><link rel="prefetch" href="/assets/js/19.6880cc9a.js"><link rel="prefetch" href="/assets/js/20.1fb3f255.js"><link rel="prefetch" href="/assets/js/21.0cd39eea.js"><link rel="prefetch" href="/assets/js/22.392d85cb.js"><link rel="prefetch" href="/assets/js/23.f50adb15.js"><link rel="prefetch" href="/assets/js/24.43e324e1.js"><link rel="prefetch" href="/assets/js/25.e3663205.js"><link rel="prefetch" href="/assets/js/26.da141fb8.js"><link rel="prefetch" href="/assets/js/27.6c05235a.js"><link rel="prefetch" href="/assets/js/28.c124245a.js"><link rel="prefetch" href="/assets/js/29.d185870d.js"><link rel="prefetch" href="/assets/js/30.8587d422.js"><link rel="prefetch" href="/assets/js/31.dc382b56.js"><link rel="prefetch" href="/assets/js/32.20ba32e9.js"><link rel="prefetch" href="/assets/js/33.6ecd7de9.js"><link rel="prefetch" href="/assets/js/34.2b91c13a.js"><link rel="prefetch" href="/assets/js/35.66ed0733.js"><link rel="prefetch" href="/assets/js/36.ce7bca84.js"><link rel="prefetch" href="/assets/js/37.d00bb5ac.js"><link rel="prefetch" href="/assets/js/38.c3ecbb6f.js"><link rel="prefetch" href="/assets/js/39.308f4175.js"><link rel="prefetch" href="/assets/js/4.520f6ecc.js"><link rel="prefetch" href="/assets/js/40.f4b98bc2.js"><link rel="prefetch" href="/assets/js/41.95fae64f.js"><link rel="prefetch" href="/assets/js/43.ca8f222e.js"><link rel="prefetch" href="/assets/js/44.4d4ee79e.js"><link rel="prefetch" href="/assets/js/45.79178b33.js"><link rel="prefetch" href="/assets/js/46.c3817d0b.js"><link rel="prefetch" href="/assets/js/47.b8252443.js"><link rel="prefetch" href="/assets/js/48.df9d5d3b.js"><link rel="prefetch" href="/assets/js/49.d812fdb2.js"><link rel="prefetch" href="/assets/js/5.f1a24a16.js"><link rel="prefetch" href="/assets/js/50.55cfcaa8.js"><link rel="prefetch" href="/assets/js/51.b8608b02.js"><link rel="prefetch" href="/assets/js/52.52c5e00d.js"><link rel="prefetch" href="/assets/js/53.3a9bd5fb.js"><link rel="prefetch" href="/assets/js/54.a4240c13.js"><link rel="prefetch" href="/assets/js/55.01c4b876.js"><link rel="prefetch" href="/assets/js/56.f29549a3.js"><link rel="prefetch" href="/assets/js/57.01438a04.js"><link rel="prefetch" href="/assets/js/58.29bb4626.js"><link rel="prefetch" href="/assets/js/59.e8b89408.js"><link rel="prefetch" href="/assets/js/6.8c478b39.js"><link rel="prefetch" href="/assets/js/60.bedb5381.js"><link rel="prefetch" href="/assets/js/61.bdfbe584.js"><link rel="prefetch" href="/assets/js/62.cb825d1a.js"><link rel="prefetch" href="/assets/js/63.a9516572.js"><link rel="prefetch" href="/assets/js/64.aa854ed7.js"><link rel="prefetch" href="/assets/js/65.285f883d.js"><link rel="prefetch" href="/assets/js/66.12849f37.js"><link rel="prefetch" href="/assets/js/67.c18b00e4.js"><link rel="prefetch" href="/assets/js/68.fa59daa9.js"><link rel="prefetch" href="/assets/js/69.e9d5dda4.js"><link rel="prefetch" href="/assets/js/7.cfb0d0ea.js"><link rel="prefetch" href="/assets/js/70.db126cce.js"><link rel="prefetch" href="/assets/js/71.6acb04cd.js"><link rel="prefetch" href="/assets/js/72.7ff0ab11.js"><link rel="prefetch" href="/assets/js/73.9a66da79.js"><link rel="prefetch" href="/assets/js/74.0a38a030.js"><link rel="prefetch" href="/assets/js/75.7b32dbb3.js"><link rel="prefetch" href="/assets/js/8.cb9c08e5.js"><link rel="prefetch" href="/assets/js/9.ad652cfe.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.110a1065.js">
    <link rel="stylesheet" href="/assets/css/0.styles.8932179b.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/images/icons/logo.png" alt="lilei" class="logo"> <span class="site-name can-hide">lilei</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/Form/" class="nav-link">
  Form
</a></div><div class="nav-item"><a href="/IDE/" class="nav-link">
  IDE
</a></div><div class="nav-item"><a href="/Java/" class="nav-link">
  Java
</a></div><div class="nav-item"><a href="/Other/" class="nav-link router-link-active">
  Other
</a></div><div class="nav-item"><a href="/Python/" class="nav-link">
  Python
</a></div><div class="nav-item"><a href="/SQL/" class="nav-link">
  SQL
</a></div><div class="nav-item"><a href="/Shell/" class="nav-link">
  Shell
</a></div><div class="nav-item"><a href="/System/" class="nav-link">
  System
</a></div> <a href="https://github.com/woytu/notes-vuepress" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/Form/" class="nav-link">
  Form
</a></div><div class="nav-item"><a href="/IDE/" class="nav-link">
  IDE
</a></div><div class="nav-item"><a href="/Java/" class="nav-link">
  Java
</a></div><div class="nav-item"><a href="/Other/" class="nav-link router-link-active">
  Other
</a></div><div class="nav-item"><a href="/Python/" class="nav-link">
  Python
</a></div><div class="nav-item"><a href="/SQL/" class="nav-link">
  SQL
</a></div><div class="nav-item"><a href="/Shell/" class="nav-link">
  Shell
</a></div><div class="nav-item"><a href="/System/" class="nav-link">
  System
</a></div> <a href="https://github.com/woytu/notes-vuepress" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Other</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/Other/" aria-current="page" class="sidebar-link">Other</a></li><li><a href="/Other/Bookmarks.html" class="sidebar-link">Bookmarks</a></li><li><a href="/Other/Markdown.html" class="sidebar-link">Markdown</a></li><li><a href="/Other/MobileNative.html" class="sidebar-link">MobileNative</a></li><li><a href="/Other/Windows软件.html" class="sidebar-link">Windows软件</a></li><li><a href="/Other/各个网站API.html" class="sidebar-link">各个网站API</a></li><li><a href="/Other/技术概念.html" class="sidebar-link">技术概念</a></li><li><a href="/Other/编程规范.html" class="sidebar-link">编程规范</a></li><li><a href="/Other/表达式和编码.html" class="active sidebar-link">表达式和编码</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#flag" class="sidebar-link">Flag</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#进制" class="sidebar-link">进制</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#逻辑运算符" class="sidebar-link">逻辑运算符</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#字符集编码" class="sidebar-link">字符集编码</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#yaml" class="sidebar-link">yaml</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#cron表达式" class="sidebar-link">Cron表达式</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#glob通配符" class="sidebar-link">Glob通配符</a></li><li class="sidebar-sub-header"><a href="/Other/表达式和编码.html#正则表达式" class="sidebar-link">正则表达式</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="表达式和编码"><a href="#表达式和编码" class="header-anchor">#</a> 表达式和编码</h1> <p></p><div class="table-of-contents"><ul><li><a href="#flag">Flag</a></li><li><a href="#进制">进制</a></li><li><a href="#逻辑运算符">逻辑运算符</a></li><li><a href="#字符集编码">字符集编码</a><ul><li><a href="#unicode">Unicode</a></li><li><a href="#ascii">ASCII</a></li></ul></li><li><a href="#yaml">yaml</a></li><li><a href="#cron表达式">Cron表达式</a></li><li><a href="#glob通配符">Glob通配符</a></li><li><a href="#正则表达式">正则表达式</a><ul><li><a href="#正则转义">正则转义</a></li><li><a href="#正则模式">正则模式</a></li><li><a href="#正则使用">正则使用</a></li></ul></li></ul></div><p></p> <h2 id="flag"><a href="#flag" class="header-anchor">#</a> Flag</h2> <blockquote><p>各种表达式以及编码</p></blockquote> <h2 id="进制"><a href="#进制" class="header-anchor">#</a> 进制</h2> <table><thead><tr><th>进制</th> <th>英文</th> <th>范围</th> <th>前缀</th> <th>后缀</th></tr></thead> <tbody><tr><td>二进制</td> <td>Binary</td> <td>0-1</td> <td>0b</td> <td>B</td></tr> <tr><td>八进制</td> <td>Octal</td> <td>0-7</td> <td>0/0O</td> <td>O</td></tr> <tr><td>十进制</td> <td>Decimal</td> <td>0-9</td> <td>无</td> <td>D</td></tr> <tr><td>十六进制</td> <td>Hexadecimal</td> <td>0-9, A-F</td> <td>0x</td> <td>H</td></tr></tbody></table> <h2 id="逻辑运算符"><a href="#逻辑运算符" class="header-anchor">#</a> 逻辑运算符</h2> <table><thead><tr><th>运算符</th> <th>说明</th></tr></thead> <tbody><tr><td>AND</td> <td>与(&amp;&amp;)</td></tr> <tr><td>EQ</td> <td>EQUAL等于(==)</td></tr> <tr><td>GE</td> <td>GREATER THAN OR EQUAL 大于等于(&gt;=)</td></tr> <tr><td>GT</td> <td>GREATER THAN大于(&gt;)</td></tr> <tr><td>LE</td> <td>LESS THAN OR EQUAL 小于等于(&lt;=)</td></tr> <tr><td>LT</td> <td>LESS THAN小于(&lt;)</td></tr> <tr><td>NE</td> <td>NOT EQUAL不等于(!=)</td></tr> <tr><td>NOT</td> <td>非(!)</td></tr> <tr><td>OR</td> <td>或(||)</td></tr></tbody></table> <h2 id="字符集编码"><a href="#字符集编码" class="header-anchor">#</a> 字符集编码</h2> <h3 id="unicode"><a href="#unicode" class="header-anchor">#</a> Unicode</h3> <ul><li><a href="http://unicode.org/reports/tr44/#GC_Values_Table" target="_blank" rel="noopener noreferrer">https://unicode.org/reports/tr44/#GC_Values_Table<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> <ul><li><a href="https://github.com/slevithan/xregexp/blob/2b652889fc14524d20f85604f291f725347f8033/src/addons/unicode-categories.js#L30" target="_blank" rel="noopener noreferrer">unicode-categories<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul> <ul><li><a href="https://www.cnblogs.com/fan-yuan/p/8176886.html" target="_blank" rel="noopener noreferrer">UniCode编码表及部分不可见字符过滤方案<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://zh.wikipedia.org/w/index.php?title=%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F#Unicode%E5%A4%84%E7%90%86" target="_blank" rel="noopener noreferrer">正则表达式#Unicode处理<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <ul><li><a href="https://unicode-table.com/cn" target="_blank" rel="noopener noreferrer">Unicode®字符百科<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://www.fuhaoku.net/blocks" target="_blank" rel="noopener noreferrer">统一码所有区段<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <blockquote><p>不可见且不占位置字符：<code>\u200D\u202A\u202B\u202C\u202D\u202E\u2060\u2061\u2062\u2063\u2064\u2065\u206A\u206B\u206C\u206D\u206E\u206F</code></p></blockquote> <table><thead><tr><th>Unicode</th> <th>意义</th></tr></thead> <tbody><tr><td>u0024</td> <td>$</td></tr> <tr><td>u0028</td> <td>(</td></tr> <tr><td>u0029</td> <td>)</td></tr> <tr><td>u002A</td> <td>*</td></tr> <tr><td>u002B</td> <td>+</td></tr> <tr><td>u002E</td> <td>.</td></tr> <tr><td>u003F</td> <td>?</td></tr> <tr><td>u005B</td> <td>[</td></tr> <tr><td>u005C</td> <td><code>\</code></td></tr> <tr><td>u005E</td> <td>^</td></tr> <tr><td>u007B</td> <td>{</td></tr> <tr><td>u007C</td> <td><code>|</code></td></tr> <tr><td>u007D</td> <td>}</td></tr> <tr><td>u0009</td> <td>t</td></tr> <tr><td>u000A</td> <td>n</td></tr> <tr><td>u000D</td> <td>r</td></tr> <tr><td>u0022</td> <td>&quot;</td></tr> <tr><td>u002C</td> <td>,</td></tr> <tr><td>u003A</td> <td>:</td></tr></tbody></table> <ul><li>GBK、GB2312等与UTF8之间都必须通过Unicode编码才能相互转换
<ul><li>GBK、GB2312 -&gt; Unicode -&gt; UTF8</li> <li>UTF8 -&gt; Unicode -&gt; GBK、GB2312</li></ul></li></ul> <blockquote><p>Unicode TransformationFormat-8bit，允许含BOM，但通常不含BOM。是用以解决国际上字符的一种多字节编码，
它对英文使用8位（即一个字节），中文使用24为（三个字节）来编码。UTF-8包含全世界所有国家需要用到的字符，是国际编码，通用性强。</p></blockquote> <blockquote><p>GBK是国家标准GB2312基础上扩容后兼容GB2312的标准。GBK的文字编码是用双字节来表示的，即不论中、英文字符均使用双字节来表示，
为了区分中文，将其最高位都设定成1。GBK包含全部中文字符，是国家编码，通用性比UTF8差，不过UTF8占用的数据库比GBK大。</p></blockquote> <h3 id="ascii"><a href="#ascii" class="header-anchor">#</a> ASCII</h3> <blockquote><p>ASCII（American Standard Code for Information Interchange，美国信息交换标准代码）是基于拉丁字母的一套电脑编码系统
，主要用于显示现代英语和其他西欧语言</p></blockquote> <blockquote><p>ASCII字符集由95个可打印字符（0x20-0x7E）（可见字符）和33个控制字符（0x00-0x1F，0x7F）（不可见字符）组成</p></blockquote> <h2 id="yaml"><a href="#yaml" class="header-anchor">#</a> yaml</h2> <p><strong>数据及文件通常有三种类型：</strong></p> <ul><li>配置文件型：如ini，conf，properties文件，适合存储简单变量和配置项，最多支持两层，不适合存储多层嵌套数据</li> <li>表格矩阵型：如csv，excel等，适合于存储大量同类数据，不适合存储层级结构的数据</li> <li>多层嵌套型：如XML，HTMl，JSON、YAML，TOML等，适合存储单条或少数多层嵌套数据，不适合存储大量数据</li></ul> <blockquote><p>YAML兼容JSON格式，简洁，强大，灵活，可以很方便的构造层级数据</p></blockquote> <table><thead><tr><th>特殊符</th> <th>说明</th></tr></thead> <tbody><tr><td><code>\n\</code></td> <td><code>\n</code>换行，\后面字符串继续写</td></tr> <tr><td><code>|</code></td> <td>文中自动换行，文末新增一空行</td></tr> <tr><td><code>|+</code></td> <td>文中自动换行，文末新增两空行</td></tr> <tr><td><code>|-</code></td> <td>文中自动换行 ，文末不新增行</td></tr> <tr><td><code>&gt;</code></td> <td>文中不自动换行，文末新增一空行</td></tr> <tr><td><code>&gt;+</code></td> <td>文中不自动换行，文末新增两空行</td></tr> <tr><td><code>&gt;-</code></td> <td>文中不自动换行，文末不新增行</td></tr></tbody></table> <h2 id="cron表达式"><a href="#cron表达式" class="header-anchor">#</a> Cron表达式</h2> <ul><li>特殊符</li></ul> <ol><li><code>*</code> 每一(每一分)</li> <li><code>?</code> 表示不关心,任意</li> <li><code>-</code> 范围 (小时:1-12,1到12点运行)</li> <li><code>,</code> 标示多个值 (小时 1,2,3 1点2点3点运行)</li> <li><code>/</code> 递增触发(0/15,从0开始每15秒运行一次)</li> <li><code>L</code> 最后(日L,当月最后一天,周L周六)</li> <li><code>W</code> 指定日期最近的工作日(周一到周五)</li> <li><code>##</code> 序号(表示每月的第几个周几)</li></ol> <ul><li>CronTrigger配置格式: [秒] [分] [小时] [日] [月] [周] [年]</li></ul> <table><thead><tr><th>序号</th> <th>说明</th> <th>是否必填</th> <th>允许填写的值</th> <th>允许的通配符</th></tr></thead> <tbody><tr><td>1</td> <td>秒</td> <td>是</td> <td>0-59</td> <td>, - * /</td></tr> <tr><td>2</td> <td>分</td> <td>是</td> <td>0-59</td> <td>, - * /</td></tr> <tr><td>3</td> <td>小时</td> <td>是</td> <td>0-23</td> <td>, - * /</td></tr> <tr><td>4</td> <td>日</td> <td>是</td> <td>1-31</td> <td>, - * ? / L W</td></tr> <tr><td>5</td> <td>月</td> <td>是</td> <td>1-12 or JAN-DEC</td> <td>, - * /</td></tr> <tr><td>6</td> <td>周</td> <td>是</td> <td>1-7 or SUN-SAT</td> <td>, - * ? / L ##</td></tr> <tr><td>7</td> <td>年</td> <td>是</td> <td>empty或1970-2099</td> <td>, - * /</td></tr></tbody></table> <h2 id="glob通配符"><a href="#glob通配符" class="header-anchor">#</a> Glob通配符</h2> <blockquote><p>glob（<code>man 7 glob</code>/<code>GLOB(7)</code>）是shell使用的路径通配符,类似于正则表达式,但是与正则表达式不完全相同</p></blockquote> <blockquote><p>glob非常强大的用途在于路径匹配，大部分的平台和开发语言都会在配置中使用glob路径匹配，其普遍性几乎使其成为一种标准。
但是需注意的是，每个平台和开发语言所支持glob路径匹配可能不完全一样。</p></blockquote> <ul><li><a href="https://github.com/isaacs/node-glob" target="_blank" rel="noopener noreferrer">https://github.com/isaacs/node-glob<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://rgb-24bit.github.io/blog/2018/glob.html" target="_blank" rel="noopener noreferrer">https://rgb-24bit.github.io/blog/2018/glob.html<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://www.ruanyifeng.com/blog/2018/09/bash-wildcards.html" target="_blank" rel="noopener noreferrer">命令行通配符教程<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <ul><li>*：匹配一个路径部分中0个或多个字符，注意不匹配以.开始的路径，如文件.a。</li> <li>?：匹配一个字符。</li> <li>[…]：匹配一系列字符，如[abc]匹配字符a, b, c，在[^…]和[!…]表示匹配不在列表中的字符，如[^abc]匹配除了a, b, c以外的字符。</li> <li>**：匹配0个或多个子文件夹。</li> <li>{a,b}：匹配a或则b，a和b也是通配符，可以由其他通配符组成。</li> <li>!：排除文件，如!a.js表示排除文件a.js。</li></ul> <h2 id="正则表达式"><a href="#正则表达式" class="header-anchor">#</a> 正则表达式</h2> <ul><li><a href="https://blog.51cto.com/hmtk520/2074219" target="_blank" rel="noopener noreferrer">grep零宽断言<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="http://tool.oschina.net/uploads/apidocs/jquery/regexp.html" target="_blank" rel="noopener noreferrer">正则表达式手册<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://harttle.land/2016/07/18/intro-to-regexp.html" target="_blank" rel="noopener noreferrer">正则表达式参考手册<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions" target="_blank" rel="noopener noreferrer">正则表达式<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://www.w3cschool.cn/regexp/2yjd1pq6.html" target="_blank" rel="noopener noreferrer">正则表达式基础知识<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://louiszhai.github.io/2016/06/13/regexp" target="_blank" rel="noopener noreferrer">https://louiszhai.github.io/2016/06/13/regexp<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://brightonzhang.com/posts/regular-expression-cheat-sheet" target="_blank" rel="noopener noreferrer">正则表达式速查手册<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li><a href="https://segmentfault.com/a/1190000018042746" target="_blank" rel="noopener noreferrer">正则全攻略使用手册<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <ul><li><a href="https://harttle.land/2016/02/23/javascript-regular-expressions.html" target="_blank" rel="noopener noreferrer">用正则表达式分析 URL<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li> <li>正则表达式搜索工具 <a href="https://github.com/BurntSushi/ripgrep" target="_blank" rel="noopener noreferrer">https://github.com/BurntSushi/ripgrep<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <h3 id="正则转义"><a href="#正则转义" class="header-anchor">#</a> 正则转义</h3> <ul><li>Escape Sequence</li></ul> <table><thead><tr><th>转义字符</th> <th>意义</th></tr></thead> <tbody><tr><td><code>\'</code></td> <td>代表一个单引号（撇号）字符</td></tr> <tr><td><code>\&quot;</code></td> <td>代表一个双引号字符</td></tr> <tr><td><code>\\</code></td> <td>代表一个反斜线字符<code>\</code></td></tr> <tr><td>\0</td> <td>空字符(NULL)</td></tr> <tr><td>\b</td> <td>退格(BS) ，将当前位置移到前一列</td></tr> <tr><td>\b</td> <td>一个单词的边界</td></tr> <tr><td>\B</td> <td>一个非单词的边界</td></tr> <tr><td>\d</td> <td>数字 等价于 [0-9]</td></tr> <tr><td>\D</td> <td>非数字 等价于 [^0-9]</td></tr> <tr><td>\ddd</td> <td>1到3位八进制数所代表的任意字符</td></tr> <tr><td>\e</td> <td>Escape</td></tr> <tr><td>\f</td> <td>换页(FF)，将当前位置移到下页开头</td></tr> <tr><td>\f</td> <td>换页符</td></tr> <tr><td>\G</td> <td>前一个匹配的结束</td></tr> <tr><td>\n</td> <td>换行(LF) ，将当前位置移到下一行开头</td></tr> <tr><td>\r</td> <td>回车(CR) ，将当前位置移到本行开头</td></tr> <tr><td>\s</td> <td>空白符号 [\t\n\x0B\f\r]</td></tr> <tr><td>\S</td> <td>非空白符号 [^\t\n\x0B\f\r]</td></tr> <tr><td>\t</td> <td>水平制表(HT) （跳到下一个TAB位置）</td></tr> <tr><td>\uhhhh</td> <td>1到2位十六进制所代表的任意字符</td></tr> <tr><td>\v</td> <td>垂直制表(VT)</td></tr> <tr><td>\w</td> <td>单独字符 [a-zA-Z_0-9]</td></tr> <tr><td>\W</td> <td>非单独字符 [^a-zA-Z_0-9]</td></tr></tbody></table> <h3 id="正则模式"><a href="#正则模式" class="header-anchor">#</a> 正则模式</h3> <table><thead><tr><th>模式</th> <th>描述</th></tr></thead> <tbody><tr><td>^</td> <td>匹配字符串的开头</td></tr> <tr><td>$</td> <td>匹配字符串的末尾。</td></tr> <tr><td>.</td> <td>匹配任意字符，除了换行符，当re.DOTALL标记被指定时，则可以匹配包括换行符的任意字符。</td></tr> <tr><td>[...]</td> <td>用来表示一组字符,单独列出：[amk] 匹配 'a'，'m'或'k'</td></tr> <tr><td>[^...]</td> <td>不在[]中的字符：[^abc] 匹配除了a,b,c之外的字符。</td></tr> <tr><td>re*</td> <td>匹配0个或多个的表达式。</td></tr> <tr><td>re+</td> <td>匹配1个或多个的表达式。</td></tr> <tr><td>re?</td> <td>匹配0个或1个由前面的正则表达式定义的片段，非贪婪方式</td></tr> <tr><td>re{ n}</td> <td>匹配n个前面表达式。例如，&quot;o{2}&quot;不能匹配&quot;Bob&quot;中的&quot;o&quot;，但是能匹配&quot;food&quot;中的两个o。</td></tr> <tr><td>re{ n,}</td> <td>精确匹配n个前面表达式。例如，&quot;o{2,}&quot;不能匹配&quot;Bob&quot;中的&quot;o&quot;，但能匹配&quot;foooood&quot;中的所有o。&quot;o{1,}&quot;等价于&quot;o+&quot;。&quot;o{0,}&quot;则等价于&quot;o*&quot;。</td></tr> <tr><td>re{ n, m}</td> <td>匹配 n 到 m 次由前面的正则表达式定义的片段，贪婪方式</td></tr> <tr><td>a</td> <td>b</td></tr> <tr><td>(re)</td> <td>匹配括号内的表达式，也表示一个组</td></tr> <tr><td>(?imx)</td> <td>正则表达式包含三种可选标志：i, m, 或 x 。只影响括号中的区域。</td></tr> <tr><td>(?-imx)</td> <td>正则表达式关闭 i, m, 或 x 可选标志。只影响括号中的区域。</td></tr> <tr><td>(?: re)</td> <td>类似 (...), 但是不表示一个组</td></tr> <tr><td>(?imx: re)</td> <td>在括号中使用i, m, 或 x 可选标志</td></tr> <tr><td>(?-imx: re)</td> <td>在括号中不使用i, m, 或 x 可选标志</td></tr> <tr><td>(?#...)</td> <td>注释.</td></tr> <tr><td>(?= re)</td> <td>前向肯定界定符。如果所含正则表达式，以 ... 表示，在当前位置成功匹配时成功，否则失败。但一旦所含表达式已经尝试，匹配引擎根本没有提高；模式的剩余部分还要尝试界定符的右边。</td></tr> <tr><td>(?! re)</td> <td>前向否定界定符。与肯定界定符相反；当所含表达式不能在字符串当前位置匹配时成功。</td></tr> <tr><td>(?&gt; re)</td> <td>匹配的独立模式，省去回溯。</td></tr> <tr><td>(?P名称)</td> <td>分组起别名</td></tr> <tr><td>(?P=name)</td> <td>引用别名为name分组匹配到的字符串</td></tr> <tr><td>\w</td> <td>匹配数字字母下划线</td></tr> <tr><td>\W</td> <td>匹配非数字字母下划线</td></tr> <tr><td>\s</td> <td>匹配任意空白字符，等价于 [\t\n\r\f]。</td></tr> <tr><td>\S</td> <td>匹配任意非空字符</td></tr> <tr><td>\d</td> <td>匹配任意数字，等价于 [0-9]。</td></tr> <tr><td>\D</td> <td>匹配任意非数字</td></tr> <tr><td>\A</td> <td>匹配字符串开始</td></tr> <tr><td>\Z</td> <td>匹配字符串结束，如果是存在换行，只匹配到换行前的结束字符串。</td></tr> <tr><td>\z</td> <td>匹配字符串结束</td></tr> <tr><td>\G</td> <td>匹配最后匹配完成的位置。</td></tr> <tr><td>\b</td> <td>匹配一个单词边界，也就是指单词和空格间的位置。例如， 'er\b' 可以匹配&quot;never&quot; 中的 'er'，但不能匹配 &quot;verb&quot; 中的 'er'。</td></tr> <tr><td>\B</td> <td>匹配非单词边界。'er\B' 能匹配 &quot;verb&quot; 中的 'er'，但不能匹配 &quot;never&quot; 中的 'er'。</td></tr> <tr><td>\n, \t</td> <td>匹配一个换行符。匹配一个制表符</td></tr> <tr><td>\1...\9</td> <td>匹配第n个分组的内容。</td></tr> <tr><td>\10</td> <td>匹配第n个分组的内容，如果它经匹配。否则指的是八进制字符码的表达式。</td></tr></tbody></table> <h3 id="正则使用"><a href="#正则使用" class="header-anchor">#</a> 正则使用</h3> <ul><li><a href="https://blog.csdn.net/wangyichina/article/details/85319194" target="_blank" rel="noopener noreferrer">一条正则表达式同时匹配IP（含有IPv6）和域名<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul> <blockquote><p><code>$1</code>、<code>\1</code>匹配获取到的值</p></blockquote> <ul><li><code>.*关键字.*\r\n</code> 指定关键字的行</li> <li><code>^(.*?)$\s+?^(?=.*^\1$)</code> 重复行</li> <li>关键字之后（包含关键字本身）的所有字符
<ul><li><code>(关键字)(.*?$)</code></li> <li><code>关键字.*$</code></li> <li><code>(关键字)([^关键字]*$)</code></li></ul></li> <li>关键字之前（包含关键字本身）的所有字符
<ul><li><code>^([^关键字]*)关键字</code></li> <li><code>^.*关键字</code></li> <li><code>(^.*?)关键字</code></li></ul></li> <li><code>(^.*?关键字.*?)关键字</code> 每行中的第二个关键字之前（包含关键字本身）的所有字符</li> <li>查找目标<code>^[^\n]*\n([^\n]*)</code> 替换为<code>\1</code>  隔行删除</li> <li>匹配不是空行的行尾：<code>(?!^$)(\n)</code></li> <li>匹配Markdown文档
<ul><li>当页跳转链接(锚点)<code>(\[)(.*)(\]\(#)(.*)(\))</code>取值<code>$4</code></li> <li>外链<code>(\[)(.*)(\]\()(.*)(\))</code>取值<code>$4</code></li></ul></li></ul> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// 匹配字母、数字及所有英文符号</span>
<span class="token operator">/</span><span class="token operator">^</span><span class="token punctuation">[</span>a<span class="token operator">-</span>z_A<span class="token operator">-</span><span class="token constant">Z0</span><span class="token operator">-</span><span class="token number">9</span><span class="token operator">-</span>\<span class="token punctuation">.</span><span class="token operator">!</span>@#\$<span class="token operator">%</span>\\\<span class="token operator">^</span><span class="token operator">&amp;</span>\<span class="token operator">*</span>\<span class="token punctuation">)</span>\<span class="token punctuation">(</span>\<span class="token operator">+=</span>\<span class="token punctuation">{</span>\<span class="token punctuation">}</span>\<span class="token punctuation">[</span>\<span class="token punctuation">]</span>\<span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">&quot;,'&lt;&gt;~\·`\?:;|]+$</span><span class="token regex-delimiter">/</span></span>

<span class="token comment">// 用户名正则，4到16位（字母，数字，下划线，减号）</span>
<span class="token keyword">var</span> uPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z0-9_-]{4,16}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>uPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;iFat3&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//密码强度正则，最少6位，包括至少1个大写字母，1个小写字母，1个数字，1个特殊字符</span>
<span class="token keyword">var</span> pPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&amp;*? ]).*$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;==&quot;</span><span class="token operator">+</span>pPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;iFat3#&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//正整数正则</span>
<span class="token keyword">var</span> posPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//负整数正则</span>
<span class="token keyword">var</span> negPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^-\d+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//整数正则</span>
<span class="token keyword">var</span> intPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^-?\d+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>posPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;42&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>negPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;-42&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>intPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;-42&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 数字正则</span>
<span class="token comment">// 可以是整数也可以是浮点数</span>

<span class="token comment">//正数正则</span>
<span class="token keyword">var</span> posPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d*\.?\d+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//负数正则</span>
<span class="token keyword">var</span> negPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^-\d*\.?\d+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//数字正则</span>
<span class="token keyword">var</span> numPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^-?\d*\.?\d+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>posPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;42.2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>negPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;-42.2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>numPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;-42.2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//Email正则：</span>
<span class="token keyword">var</span> ePattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token keyword">var</span> ePattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-z0-9A-Z]+[-|a-z0-9A-Z._]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 使用new RegExp()时\， 要变成\双斜线</span>
<span class="token keyword">var</span> reg <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span><span class="token string">&quot;^[a-z0-9A-Z]+[-|a-z0-9A-Z._]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;test@gmail.com&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> rePass <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span><span class="token string">'^([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\\_|\\.]?)*[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}$'</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 只允许英文字母、数字、下划线、英文句号、以及中划线组成</span>
<span class="token keyword">var</span> ePattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 名称允许汉字、字母、数字，域名只允许英文域名</span>
<span class="token keyword">var</span> ePattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ePattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;65974040@qq.com&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//手机号正则</span>
<span class="token keyword">var</span> mPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1][3][0-9]{9}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>mPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;13900000000&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//身份证号（18位）正则</span>
<span class="token keyword">var</span> cP <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">//输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>cP<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;11010519880605371X&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// URL正则</span>
<span class="token keyword">var</span> urlP<span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>urlP<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;http://42du.cn&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// ipv4地址正则</span>
<span class="token keyword">var</span> ipP <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>ipP<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;115.28.47.26&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 十六进制颜色正则</span>
<span class="token comment">// RGB Hex颜色正则</span>
<span class="token keyword">var</span> cPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>cPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;#b8b8b8&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 日期正则，简单判定,未做月份及日期的判定</span>
<span class="token keyword">var</span> dP1 <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d{4}(\-)\d{1,2}\1\d{1,2}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dP1<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;2017-05-11&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dP1<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;2017-15-11&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 日期正则，复杂判定</span>
<span class="token keyword">var</span> dP2 <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dP2<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;2017-02-11&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 输出 false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dP2<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;2017-15-11&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 输出 false</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>dP2<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;2017-02-29&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// QQ号正则，5至11位</span>
<span class="token keyword">var</span> qqPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1-9][0-9]{4,10}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>qqPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;65974040&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 微信号正则，6至20位，以字母开头，字母，数字，减号，下划线</span>
<span class="token keyword">var</span> wxPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>wxPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;RuilongMao&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 车牌号正则</span>
<span class="token keyword">var</span> cPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>cPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;京K39006&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// 包含中文正则</span>
<span class="token keyword">var</span> cnPattern <span class="token operator">=</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">[\u4E00-\u9FA5]</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">;</span>
<span class="token comment">// 输出 true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>cnPattern<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span><span class="token string">&quot;42度&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
 
Regex_Phones<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[0-9],$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 数字和逗号</span>
Regex_Ident<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^([a-zA-Z0-9]){1,50}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//英文、数字且不能包含英文标点和特殊符号(渠道标识)</span>
Regex_IdentName<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^([\u2E80-\u9FFF]|[a-zA-Z0-9]){1,50}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//中文、英文、数字且不能包含英文标点和特殊符号(渠道名称)</span>
Regex_MondyNum<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d+(\.\d{1,2})?$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//金额，允许两位小数</span>
Regex_MondyCh<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[\u4e00-\u9fa5]+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//只能为中文</span>
Regex_PhoneNum<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//电话号码和手机</span>
Regex_ZNum<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[1-9]\d*$</span><span class="token regex-delimiter">/</span></span> <span class="token comment">//正整数</span>
Regex_Name<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z][a-zA-Z0-9_@]{0,30}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 用户名</span>
Regex_NickName<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[\u4E00-\u9FA5A-Za-z0-9_\-]+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 中文/英文/数字， (昵称、组名、朋友备注名、内容名称、书名、页名) </span>
Regex_Passport<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^1[45][0-9]{7}$|G[0-9]{8}$|P\.[0-9]{7}$|S[0-9]{7,8}$|D[0-9]{7,8}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 护照</span>
Regex_BizLience<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^([0-9a-zA-Z]{18}$|\d{15}$)</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 营业执照,三证合一的是18位</span>
Regex_isExitZh<span class="token operator">:</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">[\u4E00-\u9FA5\uF900-\uFA2D]</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 验证是否存在中文</span>
Regex_price<span class="token operator">:</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^\d+(\.\d{1,2})?$</span><span class="token regex-delimiter">/</span></span> <span class="token comment">// 数字 . 最多两位有效数字</span>
Regex_EnghlishNum<span class="token operator">:</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(?=.*\d)(?=.*[a-z])[a-zA-Z\d]{6,20}$</span><span class="token regex-delimiter">/</span></span> <span class="token comment">//6至20位英文和数字组合</span>
Regex_Phone<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^0?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 手机号</span>
Regex_Mobile<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^0?(13[0-9]|15[012356789]|18[0-9]|14[57])[0-9]{8}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 手机号</span>
Regex_Card<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">\\d{14}[[0-9],0-9xX]</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 身份证号 </span>
Regex_Email<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z0-9]+([._\\-]*[a-zA-Z0-9])*@([a-zA-Z0-9]+[-a-zA-Z0-9]*[a-zA-Z0-9]+.){1,63}[a-zA-Z0-9]+$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 邮箱</span>
Regex_RealName<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[a-zA-Z\u4e00-\u9fa5]{0,}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 真实姓名、朋友昵称、朋友全称、组名称、组标签</span>
Regex_text<span class="token operator">:</span> <span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[\u4e00-\u9fa5]{0,}$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">// 地区 、省份、城市</span>
Regex_NumPeriod<span class="token operator">:</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^[\d]+.+。</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//数字开头，句号结尾 </span>

Regex_NumFloat<span class="token operator">:</span><span class="token regex"><span class="token regex-delimiter">/</span><span class="token regex-source language-regex">^(\-|\+)?\d+(\.\d+)?$</span><span class="token regex-delimiter">/</span></span><span class="token punctuation">,</span> <span class="token comment">//正负数字</span>
</code></pre></div><div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">function</span> <span class="token function">isUrL</span><span class="token punctuation">(</span><span class="token parameter">url</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">var</span> sRegex <span class="token operator">=</span> <span class="token string">'^((https|http|ftp|rtsp|mms)?://)'</span> <span class="token operator">+</span> <span class="token string">'?(([0-9a-z_!~*\'().&amp;=+$%-]+: )?[0-9a-z_!~*\'().&amp;=+$%-]+@)?'</span> <span class="token comment">//ftp的user@ </span>
        <span class="token operator">+</span> <span class="token string">'(([0-9]{1,3}.){3}[0-9]{1,3}'</span> <span class="token comment">// IP形式的URL- 199.194.52.184 </span>
        <span class="token operator">+</span> <span class="token string">'|'</span> <span class="token comment">// 允许IP和DOMAIN（域名） </span>
        <span class="token operator">+</span> <span class="token string">'([0-9a-z_!~*\'()-]+.)*'</span> <span class="token comment">// 域名- www. </span>
        <span class="token operator">+</span> <span class="token string">'([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].'</span> <span class="token comment">// 二级域名 </span>
        <span class="token operator">+</span> <span class="token string">'[a-z]{2,6})'</span> <span class="token comment">// first level domain- .com or .museum </span>
        <span class="token operator">+</span> <span class="token string">'(:[0-9]{1,4})?'</span> <span class="token comment">// 端口- :80 </span>
        <span class="token operator">+</span> <span class="token string">'((/?)|'</span> <span class="token comment">// a slash isn't required if there is no file name </span>
        <span class="token operator">+</span> <span class="token string">'(/[0-9a-z_!~*\'().;?:@&amp;=+$,%#-]+)+/?)$'</span><span class="token punctuation">;</span>
    <span class="token keyword">var</span> re <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">RegExp</span><span class="token punctuation">(</span>sRegex<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">//re.test() </span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>re<span class="token punctuation">.</span><span class="token function">test</span><span class="token punctuation">(</span>url<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/woytu/notes-vuepress/edit/master//Other/表达式和编码.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2021-07-20 18:19:28</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/Other/编程规范.html" class="prev">
        编程规范
      </a></span> <!----></p></div> </main></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.269009d6.js" defer></script><script src="/assets/js/3.974b9720.js" defer></script><script src="/assets/js/42.fe4f877b.js" defer></script>
  </body>
</html>
